Imports System.Collections
Imports Framework

Partial Class pages_datas_usercontrols_UCData : Inherits UserControl

#Region "Members"
    Private m_data As CData
    Private m_list As IList
#End Region

#Region "Interface"
    Public Sub Display(ByVal [data] As CData, ByVal list As IList, ByVal columns As List(Of EData), ByVal decisions As List(Of EDecision))
        plhNormal.Visible = (Parent.Controls.Count Mod 2 = 1)
        plhAlt.Visible = Not plhNormal.Visible

        m_data = [data]
        m_list = list

        With m_data
            litNumber.Text = CStr(list.IndexOf(m_data) + 1)
            lnkDataDate.Text = .DataDate.ToString("dd/MM/yyyy")
            lnkDataDate.NavigateUrl = CSitemap.DataEdit(.DataId, columns, decisions)
        End With

        For Each i As EData In columns
            UCDataColumn(plh).Display(i, m_data)
        Next
        For Each i As EDecision In decisions
            UCDataColumn(plh).Display(i, m_data)
        Next
    End Sub
#End Region

#Region "User Controls"
    Private Shared Function UCDataColumn(ByVal target As Control) As pages_datas_usercontrols_UCDataColumn
        Dim ctrl As Control = target.Page.LoadControl(CSitemap.UCDataColumn)
        target.Controls.Add(ctrl)
        Return CType(ctrl, pages_datas_usercontrols_UCDataColumn)
    End Function
#End Region

#Region "Private"
    Private Sub Refresh()
        'CCache.ClearCache()

        'If False Then 'Request.RawUrl.ToLower.Contains("myparent.aspx") Then
        '    'Special case: Parent entity owns the list
        '    Response.Redirect(CSitemap.MyParentEdit(m_data.DataParentId, MyParent.ETab.datas, m_pageIndex)
        'Else
        '    'Normal case: Search page owns the list
            Response.Redirect(Request.RawUrl) 'includes paging info
        'End If 
    End Sub
#End Region

End Class
